#include <stdlib.h>

int main()
{	
	printf("aaa\n");
	pid_t pid = fork();
	if(pid == 0)
	{
		printf("子进程开始运行，将休眠3秒\n");
		sleep(3);
		printf("子进程pid = %d\n",getpid());
		exit(122);
	}
	
	printf("父进程准备wait...\n");
	int status;
	pid_t res = wait(&status);
	printf("等待结束\n");
	printf("结束子进程pid=%d\n",res);
	printf("status = %d\n",status);
	
	if(WIFEXITED(status))
		printf("子进程正常结束，code=%d\n",WEXITSTATUS(status));
	return 0;
}
